package com.crm.customers.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.crm.base.dao.BaseDao;
import com.crm.customers.dao.PaidDao;
import com.crm.customers.model.Contract;
import com.crm.customers.model.Paid;

@Repository("paidDao")
public class PaidDaoImpl extends BaseDao implements PaidDao {

	private  static final String MAPPER_NAMESAPCE = "PaidMapper.";
	
	@Override
	public Paid savePaid(Paid c) {
		insert(MAPPER_NAMESAPCE+"savePaid", c);
		return c;
	}

	@Override
	public Paid getPaidInfoById(Paid c) {
		return selectOne(MAPPER_NAMESAPCE+"getPaidInfo", c);
	}

	@Override
	public int updatePaidApprovestate(Paid c) {
		return update(MAPPER_NAMESAPCE+"updatePaidApprovestate", c);
	}

	@Override
	public int updatePaid(Paid c) {
		return update(MAPPER_NAMESAPCE+"updatePaid", c);
	}

	@Override
	public String getOverruleReason(Paid c) {
		return selectOne(MAPPER_NAMESAPCE+"getOverruleReason", c);
	}

	@Override
	public Integer getCommMoneyByCreatedate(Paid c) {
		return selectOne(MAPPER_NAMESAPCE+"getCommMoneyByCreatedate", c);
	}

	@Override
	public List<Paid> getPaidList(Paid c) {
		List<Paid> list = selectList(MAPPER_NAMESAPCE+"getPaidList", c);
		if (list!=null && list.size() > 0) {
			list.get(0).setTotalResults((Integer)selectOne(MAPPER_NAMESAPCE+"getPaidListCount", c));
		}
		return list;
	}

	@Override
	public int getPaidTotalMoney(Paid c) {
		return selectOne(MAPPER_NAMESAPCE+"getPaidMoneyByCreatedate", c);
	}

}
